define([
    'layer',
	'../../Shop/module/STH_main.js',
], function(layer,main){
	
	return {
		tellAddM:function(con){
			
			var _this=this,
	    	    key=con.key,
	    	    order = con.order,
				prop=con.prop,
			
				newPanel=main.getPanel("tell"),	                        
		        newEdit=main.getEdit("tell");
			
			//属性操作
	        $(newPanel).attr("order",order);
	        $(newPanel).attr("key",key);
	        $(newEdit).attr("key",key);
	        $(newEdit).css("display","none");
		        
			$(newPanel).find("label").text(prop.tellNum);
			$(newEdit).find("input").val(prop.tellNum);
			
			//延时顺序重定位
	        var edLength=$(".hb_box .panel-comp").length;
			if($(".hb_box .panel-comp").length<1 || order>parseInt($(".hb_box .panel-comp").eq(edLength-1).attr("order"))){
		        	$(".hb_box").append(newPanel);
		    }else if(order < parseInt($(".hb_box .panel-comp").eq(0).attr("order"))){
		       		$(".hb_box").prepend(newPanel);
		    }else{
		       	for(var r=0; r<edLength; r++){
		       		if(order > parseInt($(".hb_box .panel-comp").eq(r).attr("order")) && order < parseInt($(".hb_box .panel-comp").eq(r+1).attr("order"))){
		       				$(".hb_box .panel-comp").eq(r).after(newPanel);
		       				break;
		       		}	       			
		       	}
		    }
			
			$(".edit-panel").append(newEdit);
			_this.tellActive(newPanel,newEdit,key);
		},

		tellActive:function(thisPanel,thisEdit,key){
			var _this=this,
				regA = /^[0-9]{3,4}\-\d{7,8}(\(\d{1,6}\))?$/,
				regB =/^1[3456789]\d{9}$/,
				regC1= /^400[0|1|6|7|8|9|]\d{6}$/,
				regC2= /^400\-[0|1|6|7|8|9|]\d{3}\-\d{3}$/;
        	if(typeof(g_data[key].prop.tellNum)=="undefined"){
	        	g_data[key].prop={
	        		"tellNum":""
	        	}
        	}
        	
        	$(thisEdit).find("input").on("blur",function(){
        		var t_val=filterXSS(main.html_encode($(this).val()));
        		if(!regA.test(t_val) && !regB.test(t_val) && !regC1.test(t_val) && !regC2.test(t_val)){
        			layer.msg("格式错误,固话需加-号,如：0571-56707020", {icon: 0, time:1500});
        			$(this).val("");
        			return false;
        		};
        		$(thisPanel).find("label").text(t_val);
        		g_data[key].prop['tellNum'] = t_val;
        	});
        	
        	//调用主模板JS
		    main.saveClick();
		    main.moduleActive();
        	main.dragEdit();
		}
	}
});